home *** CD-ROM | disk | FTP | other *** search
- #include <SetupA4.h>
- #include "ExternalInterface.h"
-
- // Spaces To Tabs by Matthew Xavier Mora
- // 3-05-93
- // Do with it what you will. But be gentle :-)
- // Since you have the source you can correct the bugs yourselves.
-
- pascal void main(ExternalCallbackBlock *callbacks, WindowPtr w)
- {
- Handle text;
- char tabChar = 0x09;
- char space = 0x20;
- GrafPtr save_port;
- long oldLength;
- EventRecord theEvent;
- register char *textptr; //ptr to text
- register char *endChar; //ending char
-
- RememberA0();
- SetUpA4();
-
- if (w == nil)
- goto exit;
-
- GetPort(&save_port);
-
- EventAvail(everyEvent,&theEvent); // Hold down the cmd key for help
- if ( theEvent.modifiers & cmdKey ) {
- Alert(128,nil);
- SetPort(save_port);
- goto exit;
- }
-
- text = callbacks->GetWindowContents(w);
- oldLength = GetHandleSize(text);
-
- HLock(text); // lock it to be safe
-
- textptr = *text;
- endChar = textptr + oldLength;
-
- for (; textptr < endChar;textptr++)
- if (*textptr == space)
- *textptr = tabChar;
-
-
- HUnlock(text);
- callbacks->ContentsChanged(w);
- exit:
- RestoreA4();
- }
-